package com.onekbase.demo.mybatis;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class D01BuildFromConfigXmlMain {
    public static void main(String[] args) throws IOException {
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
        SqlSessionFactory factory = builder.build(inputStream);

        try (SqlSession session = factory.openSession()) {
//            Object o = session.selectOne("com.onekbase.demo.mybatis.mapper.SysConfigMapper.selectConfig", "key.hello");
//            System.out.println(o);
            Object oo = session.selectOne("com.onekbase.demo.mybatis.mapper.SysConfigMapper.selectById", Arrays.asList("key.hello"));
            System.out.println(oo);
        }
    }
}
